<script>

	$(function() {

		$("#PesquisaAlunoNome").autocomplete({
			source: function( request, response ) {
				$.ajax({
					url: '<?php echo $this->Html->url(array('controller' => 'alunos', 'action' => 'pesquisar')); ?>',
					dataType: "jsonp",
					data: {
						nome: request.term
					},
					success: function( data ) {
						response( $.map( data, function( item ) {
							return {
								id: item.id,
								value: item.value
							}
						}));
					}
				});
			},
			
			minLength: 3,
			
			select: function( event, ui ) {
				$("#PesquisaAlunoId").val(ui.item.id);
				$("#PesquisaAlunoNome").val(ui.item.value);
			},
			open: function() {
				$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
			},
			close: function() {
				$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
			}
		});

	});
	
</script>

<?php

	echo '<fieldset><legend>Pesquisa</legend>';
	echo $this->Form->create('Pesquisa' , array('target' => '_blank') );
	echo $this->Form->input('aluno_id',array('type' => 'hidden'));
	echo $this->Form->input('ano', array('type' => 'text', 'label' => __('Ano'), 'class' => 'tamanho5', 'value' => date('Y')));
	echo $this->Form->input('tipo_serie_id',array('type' => 'select', 'options' => $series, 'empty' => 'Qualquer série...', 'class' => 'tamanho40', 'label' => __('Série')));
	echo $this->Form->input('turma_id',array('type' => 'select', 'options' => $turmas, 'empty' => 'Qualquer turma...', 'class' => 'tamanho20', 'label' => __('Turma')));
	echo $this->Form->input('aluno_nome', array('type' => 'text', 'label' => __('Aluno(a)'), 'class' => 'tamanho50'));
	echo '<div class="botoes_form">';
	echo $this->Form->button('Imprimir', array('type' => 'submit'));
	echo '</div>'; 	
	echo $this->Form->end();
	echo '</fieldset>';